import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'
import { Menu } from 'antd';
import { subRoutes } from '@/router'

const TopMenuItems = subRoutes.map(item => (
  <Menu.Item key={item.path}>
    {item.name}
  </Menu.Item>
))


class TopMenu extends Component {
  constructor(props) {
    super(props)
    this.state = {
      // current: '/'
    }
  }
  render() {
    const { path, handleTopMenuChange } = this.props
    return (
      <Menu
        theme="dark"
        mode="horizontal"
        selectedKeys={[path]}
        onSelect={handleTopMenuChange}
      // onClick={this.handleMenuChange}
      >
        {TopMenuItems}
      </Menu>
    )
  }
}

export default withRouter(TopMenu)
